package com.gxuwz.nio;

import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class FileChannelWrite {
    public static void main(String[] args) throws Exception {
        RandomAccessFile accessFile = new RandomAccessFile("d:\\home\\test.txt", "rw");
        FileChannel fromChannel = accessFile.getChannel();

        RandomAccessFile accessFile1 = new RandomAccessFile("d:\\home\\01.txt", "rw");
        FileChannel toChannel = accessFile1.getChannel();

        long position=0;
        long size = fromChannel.size();

//        long l = fromChannel.transferFrom(toChannel, position, size);
        long l = fromChannel.transferTo(position, size, toChannel);


    }
}
